<?php
/**
 * Created by PhpStorm.
 * User: win7
 * Date: 2018/12/22
 * Time: 14:04
 */
require 'config.php';
$name = $_POST['name'];
$auth = $_POST['auth'];
$uid = $_POST['id'];
if($_POST['yue'] == '1') {
    if ($auth == '普通用户') {
        $time = date('Y-m-d');
        $time1 = date('Y-m-d', strtotime("$time + 1 month"));
        $sql2 = "select * from jifen where uid = $uid";
        $result2 = mysqli_query($link, $sql2);
        $rows2 = mysqli_fetch_assoc($result2);
        $integal = $rows2['integral'];
        $integal1 = $integal + 30;
        $sql = "update user,jifen set jifen.integral = $integal1, user.auth = 1,user.expired ='$time1' where user.userName = '$name' and jifen.uid = '$uid'";
        mysqli_query($link, $sql);
        if (mysqli_affected_rows($link) > 0) {
            echo "<script>alert('充值成功,重新登录刷新一下');window.location.href='./index.php';</script>";die;
        }
    }
}
if($_POST['yue'] == '3') {
    if ($auth == '普通用户') {
        $time = date('Y-m-d');
        $time1 = date('Y-m-d', strtotime("$time + 3 month"));
        $sql2 = "select * from jifen where uid = $uid";
        $result2 = mysqli_query($link, $sql2);
        $rows2 = mysqli_fetch_assoc($result2);
        $integal = $rows2['integral'];
        $integal1 = $integal + 30;
        $sql = "update user,jifen set jifen.integral = $integal1, user.auth = 1,user.expired ='$time1' where user.userName = '$name' and jifen.uid = '$uid'";
        mysqli_query($link, $sql);
        if (mysqli_affected_rows($link) > 0) {
            echo "<script>alert('充值成功,重新登录刷新一下');window.location.href='./index.php';</script>";die;
        }
    }
}
if($_POST['yue'] == '6') {
    if ($auth == '普通用户') {
        $time = date('Y-m-d');
        $time1 = date('Y-m-d', strtotime("$time + 6 month"));
        $sql2 = "select * from jifen where uid = $uid";
        $result2 = mysqli_query($link, $sql2);
        $rows2 = mysqli_fetch_assoc($result2);
        $integal = $rows2['integral'];
        $integal1 = $integal + 30;
        $sql = "update user,jifen set jifen.integral = $integal1, user.auth = 1,user.expired ='$time1' where user.userName = '$name' and jifen.uid = '$uid'";
        mysqli_query($link, $sql);
        if (mysqli_affected_rows($link) > 0) {
            echo "<script>alert('充值成功,重新登录刷新一下');window.location.href='./index.php';</script>";die;
        }
    }
}


if($_POST['yue'] == '12') {
    if ($auth == '普通用户') {
        $time = date('Y-m-d');
        $time1 = date('Y-m-d', strtotime("$time + 12 month"));
        $sql2 = "select * from jifen where uid = $uid";
        $result2 = mysqli_query($link, $sql2);
        $rows2 = mysqli_fetch_assoc($result2);
        $integal = $rows2['integral'];
        $integal1 = $integal + 30;
        $sql = "update user,jifen set jifen.integral = $integal1, user.auth = 1,user.expired ='$time1' where user.userName = '$name' and jifen.uid = '$uid'";
        mysqli_query($link, $sql);
        if (mysqli_affected_rows($link) > 0) {
            echo "<script>alert('充值成功,重新登录刷新一下');window.location.href='./index.php';</script>";die;
        }
    }
}